home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / timing2.zip / TIMERS.DOC < prev    next >
Text File  |  1990-04-09  |  6KB  |  126 lines

  1.     
  2.                   TIMING AND TIME-OUT SubPrograms for QUICKBASIC
  3.                   ==============================================      
  4.  
  5.          This document discusses:
  6.          
  7.                 -Programming with the timing routines DELAY & BGDELAY.
  8.  
  9.                 -Using TIMERS.BAS and INT86.OBJ in a user run-time library.
  10.     
  11.                 -BIOS interrupt 1Ah.
  12.  
  13.               
  14.          [This document and the software it describes were prepared by 
  15.          Ken Karp. You may reach me at the QuickBASIC conference on the 
  16.          MicroSellar BBS at (201) 239-1346 (NJ), or write to me at
  17.  
  18.                                 444 Sagamore Ave. 
  19.                                 Teaneck, NJ 07666
  20.  
  21.          You are free to do ANYTHING with these files as long as you do not 
  22.          (1) distribute any changes to them under my name, or (2) attribute 
  23.          such changes to me in any way.]
  24.  
  25.  
  26.  
  27.  
  28.  
  29.          PROGRAMMING WITH THE TIMING ROUTINES DELAY & BGDELAY
  30.          ====================================================
  31.  
  32.          (1) DELAY - this SubProgram is very simple in concept. You merely 
  33.                  CALL DELAY (N!). DELAY will loop until N! hundreths of
  34.                  seconds have passed. NB: N! MUST be Single Precision (*!*)
  35.  
  36.          (2) BGDELAY - performs `background' timing while you perform some 
  37.                  other task of your own in `foreground'. For instance:
  38.  
  39.                         PRINT "You have 10 seconds to answer."
  40.  
  41.                         STATUS%=0
  42.                         H.SCNDS!=1000
  43.                         DO
  44.                                 GOSUB <do your own thing>
  45.                                 CALL BGDELAY (H.SCNDS!,TO.GO!.STATUS%)
  46.                                 Z$=INKEY$
  47.                         LOOP UNTIL Z$<>"" OR STATUS%=0
  48.  
  49.                         IF STATUS%=0 THEN
  50.                                 PRINT "Your time has expired!"
  51.                         ELSE
  52.                                 PRINT "You pressed ";z$
  53.                         END IF
  54.  
  55.                 will print the "10 seconds..." warning, and then loop until 
  56.                 EITHER a key is pressed OR 10 seconds (1000 hundredth 
  57.                 seconds) passes.  Notice that this gives you an opportunity 
  58.                 to do things on your own while you are waiting for one of 
  59.                 those two things to occur (thus the phrase `background' 
  60.                 timing).  Some of the things that you may want to do 
  61.                 include print the time remaining (like the example set 
  62.                 forth in TIMETEST.EXE), print the time of day, monitor a 
  63.                 communications port, blank out the screen after 5 minutes 
  64.                 of no typing, et.al. 
  65.  
  66.                 The parameters for BGDELAY are:
  67.  
  68.                 H.SCNDS! - hundredths of seconds you want to wait the 
  69.                         timeout occurs.
  70.                 TO.GO! - hundredths of seconds left to go (if you print 
  71.                         this out in the loop you will be `counting down' -- 
  72.                         see TIMETEST.BAS).
  73.                 STATUS% - must be set to 0 before the first call ONLY (before 
  74.                         entering the loop!); after that, TIMERS sets it 
  75.                         for you to test as follows: 1 indicates that 
  76.                         there is more time left, and 0 indicates that the 
  77.                         timeout has finally occurred.
  78.  
  79.          
  80.  
  81.          USING TIMERS.BAS IN A USER RUN-TIME LIBRARY
  82.          ===========================================
  83.  
  84.          The recommended, but not required, procedure for using TIMERS.BAS 
  85.          is to place the object file (TIMERS.OBJ) AND MicroSoft's INT86.OBJ 
  86.          into a MiscroSoft user run-time library.  The file TIMERS.EXE is
  87.          a user run-time library that contains these two object files.  
  88.  
  89.          The only restriction in usage is: IF YOU DO NOT USE TIMERS in a 
  90.          run-time library then you must not initiate a timing sequence in 
  91.          one program and CHAIN to another program to check on the timeout.  
  92.          This is due to the fact that TIMERS.OBJ maintains STATIC variables 
  93.          that must not be disrupted during the course of a single timeout 
  94.          cycle.  If you do not use CHAINing between calls, you will have no 
  95.          problem.
  96.  
  97.          If you are using the QuickBASIC v3.0 integrated environment you 
  98.          MUST place INT86.OBJ into a run time library.  TIMERS.OBJ may be 
  99.          placed into the same run-time library, or TIMERS.BAS may be 
  100.          $INCLUDEd into your source code.
  101.  
  102.          If you are using static library(s) (ie, .LIB files), you may add 
  103.          TIMERS.OBJ and INT86.OBJ to them, or you may add them as object 
  104.          modules at LINK time (eg, LINK MYPROG+TIMERS+INT86+...+,...).
  105.          
  106.  
  107.          NB:  INT86.OBJ (and INT86.ASM) are distributed with QuickBASIC 
  108.          v3.0.  INT86.OBJ may be called from a QuickBASIC v3.0 program to 
  109.          perform any 8086 interrupt.  TIMERS uses it to perform BIOS 
  110.          interrupt 1Ah (see below).
  111.  
  112.  
  113.  
  114.          BIOS INTERRUPT 1Ah
  115.          ==================
  116.  
  117.          BIOS interrupt 1Ah performs time of day functions.  TIMERS calls 
  118.          interrupt 1Ah with an argument of 0 in AH to obtain the clock 
  119.          ticks since midnight.  Although BIOS's change from one PC 
  120.          "compatible" computer to another, this particular call is very 
  121.          fundamental, and I would expect most (if not all) clones to 
  122.          service it.  If you find that TIMERS does not work as expected on 
  123.          your machine, and you wish to get it to work, you may contact me 
  124.          as outlined at the beginning of this document and I will try to 
  125.          help you.
  126.